<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>用户登录</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/login-background.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/login-styles.css" type="text/css" media="screen" />
<script src="${pageContext.request.contextPath}/js/login-background.js" type="text/javascript" charset="utf-8"></script>
<jsp:include page="../../inc.jsp"></jsp:include>
<script type="text/javascript">
	$(function() {
		$('#user-login-form').form({
			url : '${pageContext.request.contextPath }/userAction!doNotNeedSession_login.action',
			onSubmit : function() {
				var validate = $("#user-login-form").form("validate");
				if(validate) {
					$.messager.progress({
						text : "提交数据，请等待..."
					});
				}
				return validate;
			},
			success : function(data) {
				var d = $.parseJSON(data);
				if (d.success) {
					window.location.href = "${pageContext.request.contextPath}/";
				} else {
					$('#user-login').find('input[name=name]').focus();
					if (d.obj) {
						eval(d.obj);
					} else {
						$.messager.show({
							msg : d.msg,
							title : '提示'
						});
					}
				}
				$.messager.progress('close'); //关闭进度条
			}
		});

		//如果有id说明已经登陆过了
		if ('null' != '${userSession.id}' && '' != $.trim('${userSession.id}')) {
			window.location.href = "${pageContext.request.contextPath}/";
		}

		//增加回车提交
		$('#user-login-form input').on('keyup', function(event) {
			if (event.keyCode == '13') {
				$("#user-login-form").submit();
			}
		});
	});
</script>
</head>
<body>
	<div id="box">
		<img src="${pageContext.request.contextPath}/images/logo.png" class="logo" alt="yourlogo" />
		<h1>用户登录</h1>
		<form id="user-login-form">
			<input type="text" id="name" name="name" class="easyui-validatebox" data-options="required:true" /> 
			<input type="password" id="pwd" name="pwd" class="easyui-validatebox" data-options="required:true" /> 
			<!--input type="checkbox" id="remember" value="Remember" />
			<div class="hover-opacity">
				<label for="remember">Remember me</label>
			</div-->
			<input type="button" name="" value="Log In" onclick="$('#user-login-form').submit();"/>
		</form>
	</div>
	<!-- a href="http://www.divmb.com" class="forgot">Forgot your username or password?</a-->
</body>
</html>